<template>
  <div class="box">
    <img src="imgurl" alt="" />
    <p :style="{ backgroundColor: colorStr }" @click="fn">{{ dogname }}</p>
  </div>
</template>

<script>
export default {
  props: ["imgurl", "dogname"],
  data() {
    return {
      colorStr: "",
    };
  },
  methods: {
    fn() {
      this.colorStr = `rgb(${Math.floor(Math.random() * 256)},
        ${Math.floor(Math.random() * 256)},${Math.floor(Math.random() * 256)}
        )`;
      this.$emit("arr1", this.dogname);
    },
  },
};
</script>

<style scoped>
.box {
  width: 200px;
  border: 1px solid black;
  text-align: center;
  float: left;
}

.box img {
  width: 100%;
  height: 200px;
}
</style>
